package com.itheima.day02.ZuoYe.ZuoYe_3;

import java.util.ArrayList;

//掌握Java中String以及Integer的使用
public class ZuoYe_3 {
    public static void main(String[] args) {
        // 准备学生数据
        Student s = new Student("艾大海", "A230602820", "男", 25, "大专以下", "永州职业技术学员");
        Student s2 = new Student("曹少坤", "A230601537", "男", 23, "本科及以上", "");
        Student s3 = new Student("陈橙", "A230600767", "男", 21, "大专 ", "湖南软件职业学员");
        Student s4 = new Student("陈福", "A230601913", "男", 21, "大专", "湖南机电职业技术学员");
        Student s5 = new Student("陈美鹃", "A230600523", "男", 25, "本科及以上", "");
        Student s6 = new Student("陈鑫", "A230601837", "男", 21, "大专以下", "长查民政职业技术学员");
        Student s7 = new Student("陈泳名", "A230601852", "男", 23, "大专", "湖南信息职业技术学员");
        Student s8 = new Student("邓灿宇", "A230601109", "男", 22, "大专", "");
        Student s9 = new Student("邓明", "A230601830", "男", 21, "大专以下", "");
        Student s10 = new Student("付云杰", "A230603250", "男", 22, "大专", "湘西名族职业技术学员");
        Student s11 = new Student("胡振宇", "A230601217", "男", 25, "本科及以上", "湖南涉外经济学员");
        Student s12 = new Student("黄永麒", "A210302017", "男", 23, "本科及以上", "湖南涉外经济学员");
// 创建集合，添加学生数据
        ArrayList <Student> list = new ArrayList<>();
        list.add(s);
        list.add(s2);
        list.add(s3);
        list.add(s4);
        list.add(s5);
        list.add(s6);
        list.add(s7);
        list.add(s8);
        list.add(s9);
        list.add(s10);
        list.add(s11);
        list.add(s12);
        // 从以上的字符串中，获取"陈"和22，然后从集合中把满足条件的学生信息在控制台打印出来！！！
        String url = "https://tlias.itcast.cn/tz/classStudentList?name=邓&age=21";
        int start = url.indexOf("=")+1;
        int end = url.indexOf("&");
        String param = url.substring(start, end);
        System.out.println(param);
        int index = url.lastIndexOf("=");
        String age = url.substring(index);
//        for (int i = 0; i < list.size(); i++) {
//            if(list.get(i).getName().contains("邓")&&list.get(i).getAge()==21){
//                System.out.println(list.get(i));
//            }
//        }
    }
}
//import java.util.ArrayList;
//import java.util.regex.Matcher;
//import java.util.regex.Pattern;
//
//public class StudentFilter {
//    public static void main(String[] args) {
//        // 给定的Java代码字符串
//        String input = "Student s = new Student(\"艾大海\", \"A230602820\", \"男\", 25, \"大专以下\", \"永州职业技术学员\");\n" +
//                "Student s2 = new Student(\"曹少坤\", \"A230601537\", \"男\", 23, \"本科及以上\", \"\");\n" +
//                "Student s3 = new Student(\"陈橙\", \"A230600767\", \"男\", 21, \"大专 \", \"湖南软件职业学员\");\n" +
//                "Student s4 = new Student(\"陈福\", \"A230601913\", \"男\", 21, \"大专\", \"湖南机电职业技术学员\");\n" +
//                "Student s5 = new Student(\"陈美鹃\", \"A230600523\", \"男\", 25, \"本科及以上\", \"\");\n" +
//                "Student s6 = new Student(\"陈鑫\", \"A230601837\", \"男\", 21, \"大专以下\", \"长查民政职业技术学员\");\n" +
//                "Student s7 = new Student(\"陈泳名\", \"A230601852\", \"男\", 23, \"大专\", \"湖南信息职业技术学员\");\n" +
//                "Student s8 = new Student(\"邓灿宇\", \"A230601109\", \"男\", 22, \"大专\", \"\");\n" +
//                "Student s9 = new Student(\"邓明\", \"A230601830\", \"男\", 21, \"大专以下\", \"\");\n" +
//                "Student s10 = new Student(\"付云杰\", \"A230603250\", \"男\", 22, \"大专\", \"湘西名族职业技术学员\");\n" +
//                "Student s11 = new Student(\"胡振宇\", \"A230601217\", \"男\", 25, \"本科及以上\", \"湖南涉外经济学员\");\n" +
//                "Student s12 = new Student(\"黄永麒\", \"A210302017\", \"男\", 23, \"本科及以上\", \"湖南涉外经济学员\");";
//
//        // 正则表达式匹配Student对象创建语句
//        Pattern pattern = Pattern.compile(
//                "new Student\\(\"([^\"]+)\",\\s*\"([^\"]+)\",\\s*\"([^\"]+)\",\\s*(\\d+),\\s*\"([^\"]*)\",\\s*\"([^\"]*)\"\\)"
//        );
//
//        ArrayList<Student> list = new ArrayList<>();
//        Matcher matcher = pattern.matcher(input);
//
//        // 提取数据并创建Student对象
//        while (matcher.find()) {
//            String name = matcher.group(1);
//            String id = matcher.group(2);
//            String gender = matcher.group(3);
//            int age = Integer.parseInt(matcher.group(4)); // 字符串转int
//            String education = matcher.group(5);
//            String school = matcher.group(6);
//
//            list.add(new Student(name, id, gender, age, education, school));
//        }
//
//        // 筛选姓"邓"且年龄为21的学生
//        ArrayList<Student> resultList = new ArrayList<>();
//        for (Student student : list) {
//            if (student.getName().startsWith("邓") && student.getAge() == 21) {
//                resultList.add(student);
//            }
//        }
//
//        // 打印结果
//        System.out.println("姓邓且年龄21的学生:");
//        System.out.println("---------------------------------------------");
//        System.out.printf("%-10s %-15s %-4s %-8s %-10s %-20s%n",
//                "姓名", "学号", "性别", "年龄", "学历", "学校");
//        System.out.println("---------------------------------------------");
//
//        for (Student stu : resultList) {
//            System.out.printf("%-10s %-15s %-4s %-8d %-10s %-20s%n",
//                    stu.getName(),
//                    stu.getId(),
//                    stu.getGender(),
//                    stu.getAge(),
//                    stu.getEducation(),
//                    stu.getSchool());
//        }
//        System.out.println("---------------------------------------------");
//    }
//}
//
//// 学生类定义
//class Student {
//    private String name;
//    private String id;
//    private String gender;
//    private int age;
//    private String education;
//    private String school;
//
//    public Student(String name, String id, String gender, int age, String education, String school) {
//        this.name = name;
//        this.id = id;
//        this.gender = gender;
//        this.age = age;
//        this.education = education;
//        this.school = school;
//    }
//
//    // Getter方法
//    public String getName() { return name; }
//    public String getId() { return id; }
//    public String getGender() { return gender; }
//    public int getAge() { return age; }
//    public String getEducation() { return education; }
//    public String getSchool() { return school; }
//}